<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Circulate Example</title>
</head>

<body>
   
</body>
<script>
    var i = 1;
    do {

        i++;
        if (i == 5) {
            break; // 当 i 等于 5 时，跳出循环
        }
    } while (i <= 6);
    do {

        i++;
        if (i == 5) {
            continue; // 当 i 等于 5 时，跳出循环
        }
    } while (i <= 6);

    var arr = [1, 2, 3, 4, 5];
    for (var item of arr) {
        if (item == 3) {
            continue; // 当 i 等于 5 时，跳出循环
        } else {
            console.log(item);
        }
    }
    for (var item of arr) {
        if (item == 3) {
            break; // 当 i 等于 5 时，跳出循环
        } else {
            console.log(item);
        }
    }

    var x
    var mycars = new Array()
    mycars[0] = "Saab"
    mycars[1] = "Volvo"
    mycars[2] = "BMW"
    for (x in mycars) {
        if (x == 2) {
            break; // 当 i 等于 5 时，跳出循环 
        }
        console.log(mycars[x]);
    }
    for (x in mycars) {
        if (x == 2) {
            continue; // 当 i 等于 5 时，跳出循环
        }
        console.log(mycars[x]);
    }

    var arrayAll = [];
    arrayAll.push(1);
    arrayAll.push(2);
    arrayAll.push(3);
    arrayAll.push(4);

    arrayAll.forEach(function (item, index) {
        if (item == 3) {
            return; // 当 i 等于 5 时，跳出循环
        } else {
            console.log(item);
        }
    })

    // 等腰三角形
    for (var i = 1; i < 10; i++) {
        let line = '';
        for (var j = 1; j <= 10 - i; j++) {
            line += '&nbsp';
        }
        for (var j = 0; j < i; j++) {
            line += '*';

        }
        document.write(line + '<br>')
    }
    document.write('--------------------------------');

    // 九九乘法表
    for (var i = 1; i <= 10; i++) {
        let line = '';
        for (var j = 1; j < i; j++) {
            line += `${i - 1} * ${j} = ${(i - 1) * j}` + ' ';
        }
        document.write(line + '<br>')
    }

    document.write('--------------------------------');
    document.write('<br>')

    // 一百以内的偶数
    var j = 0;
    document.write("1-100间的偶数为：")
    for (var i = 1; i <= 100; i++) {
        if (i % 2 == 0 && i > 0) {
            document.write(i + '&nbsp &nbsp')
            j++;
        }
    }
    document.write('<br>')
    document.write("1-100间的偶数总和为："+ j + "个")
    document.write('<br>')
    document.write('--------------------------------')
    document.write('<br>')

    // 一百以内的奇数
    var j = 0;
    document.write("1-100间的奇数为：")
    for (var i = 0; i <= 100; i++) {
        if (i % 2 != 0 && i > 0) {
            document.write(i + '&nbsp &nbsp')
            j++;
        }
    }
    document.write('<br>')
    document.write("1-100间的奇数总和为："+ j + "个")
    document.write('<br>')

    

    //计算某年是闰年还是平年
    var year = prompt("请输入年份:");
    if (year % 4 ==0 && year % 100!=0 || year % 400 == 0){
        document.write(year + "年是闰年");
    }else{
        document.write(year + "年是平年");
    }
</script>

</html>